//
//  ViewController.m
//  Do_exercise
//
//  Created by shigzzz on 15/7/1.
//  Copyright (c) 2015年 asiainfo. All rights reserved.
//

#import "ViewController.h"
#import "UIInit.h"

@interface ViewController ()

//@property (strong,nonatomic) UIButton *gitButton;
@property (strong,nonatomic) UIToolbar *tool;
@property (strong,nonatomic) UIButton *baiduButton;
@property (strong,nonatomic) UIButton *helpButton;
@property (strong,nonatomic) UIImage *image;
@property (strong,nonatomic) UIImageView *iconView;
@property (strong,nonatomic) UITextField *textField;
@property (strong,nonatomic) UIButton *searchButton;
@property (strong,nonatomic) UIAlertView *alert;
@property (strong,nonatomic) UILabel *label;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any adzditional setup after loading the view, typically from a nib.
    [self initView];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


- (void)buttonOnclick:(UIButton *)sender {
    self.alert= [[UIAlertView alloc] initWithTitle:@"alert"
                 // message:@"do you want to ....";
                 //获取按钮上的字sender.titleLabe.text
                                           message:sender.titleLabel.text
                 
                                          delegate:self
                                 cancelButtonTitle:@"yes"
                                 otherButtonTitles:@"no",
                 nil];
    [self.alert show];
}

#pragma mark - details
- (void)initView {
    //百度
    //    self.baiduButton = [UIButton buttonWithType:UIButtonTypeCustom];
    //    [self.baiduButton setFrame:CGRectMake(30,20,50,20)];
    //    [self.baiduButton setTitle: @"百度" forState:UIControlStateNormal];
    //    [self.baiduButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    self.baiduButton = [UIInit buttonWithTitle:@"百度" andFrame:CGRectMake(30, 20, 50, 20)];
    [self.baiduButton addTarget:self action:@selector(buttonOnclick:) forControlEvents:UIControlEventTouchUpInside];
    
    
    //帮助我们
    //    self.helpButton = [UIButton buttonWithType: UIButtonTypeCustom];
    //    [self.helpButton setFrame: CGRectMake(100, 20, 100, 20)];
    //    [self.helpButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //    [self.helpButton setTitle:@"帮助我们" forState:UIControlStateNormal];
    self.helpButton = [UIInit buttonWithTitle:@"帮助我们" andFrame:CGRectMake(100, 20, 100, 20)];
    [self.helpButton addTarget:self action:@selector(buttonOnclick:) forControlEvents:UIControlEventTouchUpInside];
    //工具栏
    self.tool = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, 1024, 40)];
    [self.tool setTintColor:[UIColor blackColor]];
    [self.tool setBackgroundColor:[UIColor blackColor]];
    [self.tool addSubview:self.baiduButton];
    [self.tool addSubview:self.helpButton];
    //[self.tool addSubview:self.baiduButton];
    [self.view addSubview:self.tool];
    
    //图片
    self.iconView = [[UIImageView alloc]init];
    [self.iconView setFrame:CGRectMake(300, 200, 300, 300)];
    self.iconView.image = [UIImage imageNamed:@"google"];
    [self.view addSubview:self.iconView];
    
    //文本框textField
    self.textField = [[UITextField alloc]initWithFrame:CGRectMake(300, 500, 300, 40)];
    [self.textField.layer setBorderColor:[UIColor grayColor].CGColor];
    [self.textField.layer setBorderWidth:1];
    [self.view addSubview:self.textField];
    
    //搜索button
    //    self.searchButton = [UIButton buttonWithType:UIButtonTypeCustom];
    //    [self.searchButton setFrame:CGRectMake(650, 500, 40, 40)];
    //    [self.searchButton setTitle:@"搜索" forState:UIControlStateNormal];
    //    [self.searchButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    self.searchButton = [UIInit buttonWithTitle:@"搜索" andFrame:CGRectMake(650, 500, 40, 40)];
    [self.searchButton.layer setBorderWidth:1];
    [self.searchButton.layer setBorderColor:[UIColor blackColor].CGColor];
    [self.view addSubview:self.searchButton];
    
    
    //文本标签
    //    self.label=[[UILabel alloc]initWithFrame:CGRectMake(40, 700, 200, 30)];
    //[self.label setText:@"关于我们"];
    self.label = [UIInit labelWithText:@"关于我们" andFrame:CGRectMake(40, 700, 200, 30)];
    [self.view addSubview:self.label];
    
}


@end
